Retropikzel's blog - 2025-12-24 - Making a Scheme script on windows

This is going to be a lot shorter than the unix one. Because I do not know why it works (on the batch side of things), nor do I particularly care. :D But I thought I’d share it anyway.

On windows to make a Scheme script that runs itself you can make it like this:

main.bat:


                ; @echo off & gosh -r7 "%~f0" %* & exit /b
                (import (scheme base)
                        (scheme write))

                (display "Hello")
                (newline)
            

Run it from powershell or cmd prompt with ..bat

The script calls gosh(.exe) with the full path of the file itself (%~f0) as first argument and passes all arguments (%*) passed to it to the script. The scheme interpreters runs and since the first line starts with ; it is ignored.